<?php

namespace app\controllers;

use yii\i18n\GettextPoFile;
use yii\web\HttpException;
use app\logic\PositionLogic;
use app\components\Controller;

/**
 * 岗位
 */
class PositionController extends Controller
{
    protected function verbs()
    {
        return [
            'create' => ['POST'],
            'update' => ['POST'],
            'delete' => ['POST'],
            'view' => ['GET'],
            'get-info' => ['GET'],
            'get-param' => ['GET'],
            'get-item-data' => ['GET'],
            'get-default-item' => ['GET'],
        ];
    }

    /**
     * 创建 岗位
     * @throws HttpException
     */
    public function actionCreate()
    {
        return PositionLogic::create(getParams());
    }

    /**
     * 编辑 岗位
     * @throws HttpException
     */
    public function actionUpdate()
    {
        return PositionLogic::update(getParams());
    }

    /**
     * 详情 岗位
     * @return array
     * @throws HttpException
     */
    public function actionView()
    {
        return PositionLogic::view(getParams());
    }

    /**
     * 删除 岗位
     * @throws HttpException
     * @throws \Throwable
     */
    public function actionDelete()
    {
        return PositionLogic::delete(getParams());
    }

    /**
     * 岗位 下拉列表 （ 岗位、用户 添加&编辑 使用 ）
     * @return array
     * @throws HttpException
     */
    public function actionGetDropList()
    {
        return PositionLogic::getDropList(getParams());
    }

    /**
     * 岗位 编辑时的信息
     * @return array
     * @throws HttpException
     */
    public function actionGetInfo()
    {
        return PositionLogic::getInfo(getParams());
    }

    /**
     * 自定义数据授权 组织&部门树形
     * @return array
     * @throws HttpException
     */
    public function actionGetItemData()
    {
        return PositionLogic::getItemData(getParams());
    }

    /**
     * 岗位 默认的权限项树形
     * @return array
     * @throws HttpException
     */
    public function actionGetDefaultItem()
    {
        return PositionLogic::getDefaultItem(getParams());
    }

    /**
     * 某组织｜某部门 下的 岗位树形
     * @return array|array[]
     * @throws HttpException
     */
    public function actionGetTreeList()
    {
        return PositionLogic::getTreeList(getParams());
    }
}
